;;;; Created on 2012-11-26 20:46:14



(defun part_a (sentence)
  "Runs the tests for Part A"
  (dolist (i sentence)
    (write-line (format nil "(part_a ~A ~A)" i (wfp-checker i)))
  ))

(defun part_b (sentence interpretation)
  "Runs the tests for Part b"
  ;(write-line (format nil "interpretation ~A" interpretation ))
  ;(write-line (format nil "-----------------------------------"))
  (dolist (i sentence)
    (write-line (format nil "(part_b ~A ~A)" i (TruthValue  i interpretation)))
    ))

(defun part_b_tautology (sentence)
  "Runs the tests for the tautology portion of part b"
  (dolist (i sentence)
  ;(write-line (format nil "(part_a ~A ~A)" sentence (wfp-checker sentence)))
  ;(write-line (format nil "(part_b ~A ~A)" i (TruthValue  i)))
  (write-line (format nil "(part_b ~A ~A)" i (IsTautology i)))
  ))

(defun part_c (sentence)
  "Runs the test for part c"
  (dolist (i sentence)
  ;(write-line (format nil "(part_c ~A ~A)" sentence (wfp-checker sentence)))
  (write-line (format nil "(part_c ~A ~A)" i (wfp-checkerFOL i)))
  ))



;====================================================================================================


(defun load-start-states (sentence )
  "Loads the start states for the STRIPS operator"
  (dolist (i sentence)
    (write-line (format nil "(part_d ~A ~A)" i (wfp-checkerFOL i)))
  ))


(defun load-goal-states (sentence )
  "Loads the goal states for the STRIPS operator"
  (dolist (i sentence)
    (write-line (format nil "(part_d ~A ~A)" i (wfp-checkerFOL i)))
  ))


(defun load-operators (sentence )
  "Loads the operators for the STRIPS operator"
  (dolist (i sentence)
    (dolist (x i)
      (write-line (format nil "(part_d ~A ~A)" x (wfp-checkerFOL x)))
      )
  ))


;====================================================================================================


(defun parta-tests ()
  "Unit Tests for part_A"
  ; should pass
  (case? "BOB")
  (case? "B12")
  (case? "P")
  (case? "John is up")

  ; should fail
  (case? "p")
  (case? "B12B")
  (case? "a12")
  (case? "123")
  (case? "John is up")

  ; should fail
  (wfp-checker '(f f f))
  (wfp-checker '(john is up))
  (wfp-checker 'p)
  (wfp-checker '(p q))
  (wfp-checker '(AND (OR P (NOT Q)) (OR (NOT P) Q)))
  (wfp-checker '(NOT P))
  (wfp-checker '(IMPLIES P (Q)))
  (wfp-checker '(IMPLIES (P) Q))
  (wfp-checker '(EQUIV (P) Q))
  (wfp-checker '(EQUIV P (Q)))
  (wfp-checker '(|p|))
  ;Should Pass
  (wfp-checker '(P))
  (wfp-checker '(|P|))
  (wfp-checker '("John is up"))
  (wfp-checker '(NOT (P)))
  (wfp-checker '(IMPLIES (P) (Q)))
  (wfp-checker '(EQUIV (P) (Q)))
  (wfp-checker '(AND (OR (P) (NOT (Q))) (OR (NOT (P)) (Q))))  
)


(defun partb-tests ()
  "Unit Tests for part_B"
  ;Should Fail
  (TruthValue '((P t) (Q nil)) '(IMPLIES (P) (Q)))
  (TruthValue '((P t) (Q nil)) '(and (P) (Q)))
  (TruthValue '((P t) (Q nil) (P2 t)) '(and (P) (Q) (P2)))
  (TruthValue '((P t)) '(not (P)))
  (TruthValue '((P nil) (Q nil)) '(or (P) (Q)))


 ;Should Succeed
  (TruthValue '((P t) (Q t)) '(or (P) (Q)))
  (TruthValue '((P t) (Q nil)) '(or (P) (Q)))
  (TruthValue '((P nil) (Q t)) '(or (P) (Q)))
  (TruthValue '((P t) (Q t)) '(and (P) (Q)))
  (TruthValue '((P t) (Q t)) '(IMPLIES (P) (Q)))
  (TruthValue '((P nil)) '((not) (P)))
  (TruthValue '((P t) (Q t)) '(EQUIV (P) (Q)))
  (TruthValue '((P nil) (Q nil)) '(EQUIV (P) (Q)))
  
  
  
  (IsTautology '(OR (P) (NOT (P))))
  (IsTautology '(IMPLIES (P) (Q)))
  (IsTautology '(and (P) (Q)))
  (IsTautology '(EQUIV (P) (Q)))
  (IsTautology '(EQUIV (IMPLIES (P)(Q)) (OR (NOT (P))(Q))))
)




(defun partc-tests ()
  "Unit Tests for part_C"
  
  ;Should Pass
  (part_c '((P)))
  (part_c '((P |a|)))
  (part_c '((P |x|)))
  (part_c '((P |a| |b|)))
  (part_c '((AND (I |x|) (P |y|))))
  (part_c '((AND (S |e| |y|) (I |d|))))
  (part_c '((P |a| |b| |c|)))
  (part_c '((P (|f| |a|))))
  (part_c '((P (|f| |a| |b|))))
  (part_c '((P (|a| |b|))))
  (part_c '((P (|f| |a|))))
  (part_c '((NOT (P |x|))))
  (part_c '((NOT (P |x| |y| |z|))))
  (part_c '((NOT (P |a| |b| |z|))))
  (part_c '((OR (P |x| |y| |z|))))
  (part_c '((OR(P |a| ) (Q |b| ))))
  (part_c '((OR (P))))
  (part_c '((IMPLIES (P |a| ) (Q |b| ))))
  (part_c '((EQUIV (P |a| ) (Q |b| ))))
  (part_c '((ALL |v| (P |v|(|f| |v|)))))
  (part_c '((ALL |x| |y| (P |x| |y|))))
  (part_c '((EXISTS |v| ( P |v|(|f| |v|)))))
  
  (part_c '((IMPLIES (Q |u| (|f| |a| |v|) |d|) (R (|g| (|h| |b| |c| |w|)) |y|))))
  (part_c '((AND (S |e| |y|) (J |d|))))
  
  ;Should Fail
  (part_c '((P |f|)))
  (part_c '((P |a| |f|)))
  (part_c '((P (|a| |f|))))
  (part_c '((IMPLIES (NOT (OR (P |a|) (Q |b|)))  Q |c|)))
  ;(part_c '((EXISTS |v| (P |v| (|v| |f|)))))
  
  
  (is-alltermsp "ab")
  (is-alltermsp '(|a| |b|))
  (is-alltermsp '(|a| |z|))
  (is-alltermsp '(|a| |f|))
  
  (term-type "a")
  (term-type "f")
  (term-type "v")
  (term-type "A")
  
  (termp "a")
  (termp "f")
  (termp "v")
  (termp "P")
  (predicatep "a")
  (predicatep "f")
  (predicatep "v")
  (predicatep "P")
  (funcp "a")
  (funcp "f")
  (funcp "v")
  (funcp "P")
  
  )
